//
//  CellOfDetailsPageDestinationSearchResult.m
//  FreeTravel
//
//  Created by 徐康 on 16/9/2.
//  Copyright © 2016年 KX. All rights reserved.
#import "UIImageView+WebCache.h"
#import "Masonry.h"
#import "CellOfDetailsPageDestinationSearchResult.h"
@interface CellOfDetailsPageDestinationSearchResult ()
@property (nonatomic, strong) UIImageView *imageViewOfPhoto;
@property (nonatomic, strong) UILabel *labelOfCnnamel;
@property (nonatomic, strong) UILabel *labelOfEnname;
@property (nonatomic, strong) UILabel *labelOfparentname;
@property (nonatomic, strong) UILabel *labelOfBeenstr;
@property (nonatomic, strong) UILabel *labelOfLabel;
@end
@implementation CellOfDetailsPageDestinationSearchResult
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageViewOfPhoto = [[UIImageView alloc]init];
        self.labelOfLabel = [[UILabel alloc]init];
        self.labelOfCnnamel = [[UILabel alloc]init];
        self.labelOfEnname = [[UILabel alloc]init];
        self.labelOfparentname = [[UILabel alloc]init];
        self.labelOfBeenstr = [[UILabel alloc]init];
        [self.contentView addSubview:self.imageViewOfPhoto];
        [self.contentView addSubview:self.labelOfBeenstr];
        [self.contentView addSubview:self.labelOfparentname];
        [self.contentView addSubview:self.labelOfEnname];
        [self.contentView addSubview:self.labelOfCnnamel];
        [self.contentView addSubview:self.labelOfLabel];
    }
    return self;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    
    [self.imageViewOfPhoto mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.contentView).mas_offset(10);
        make.bottom.equalTo(self.contentView).mas_offset(-10);
        make.height.width.mas_offset(130);
    }];
    [self.labelOfCnnamel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(10);
        make.left.equalTo(self.imageViewOfPhoto.mas_right).mas_offset(10);
        make.height.mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-40);
    }];
    [self.labelOfBeenstr mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageViewOfPhoto.mas_right).mas_offset(10);
        make.bottom.equalTo(self.contentView.mas_bottom).mas_offset(-10);
        make.height.mas_offset(10);
        make.right.equalTo(self.contentView.mas_right).mas_offset(-40);
    }];
    self.labelOfBeenstr.textColor = [UIColor grayColor];
    self.labelOfBeenstr.font = [UIFont systemFontOfSize:12];
    [self.labelOfEnname mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.labelOfCnnamel.mas_bottom).mas_offset(10);
        make.left.equalTo(self.imageViewOfPhoto.mas_right).mas_offset(10);
        make.height.mas_offset(12);
        make.right.equalTo(self.contentView).mas_offset(-40);
    }];
    self.labelOfEnname.textColor = [UIColor grayColor];
    self.labelOfEnname.font = [UIFont systemFontOfSize:12];
    [self.labelOfparentname mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.labelOfBeenstr.mas_top).mas_offset(-5);
        make.left.equalTo(self.imageViewOfPhoto.mas_right).mas_offset(10);
        make.height.mas_offset(10);
        make.right.equalTo(self.contentView).mas_offset(-40);
    }];
    self.labelOfparentname.textColor = [UIColor grayColor];
    self.labelOfparentname.font = [UIFont systemFontOfSize:12];
    [self.labelOfLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView.mas_right).mas_offset(-10);
        make.width.mas_offset(30);
        make.height.mas_offset(12);
    }];
    self.labelOfLabel.textColor = [UIColor grayColor];
    self.labelOfLabel.font = [UIFont systemFontOfSize:12];
}
- (void)setModel:(ModelOfDestinationSpecificSearchResult *)model{
    _model = model;
    [self.imageViewOfPhoto sd_setImageWithURL:[NSURL URLWithString:model.photo]];
    self.labelOfLabel.text = model.label;
    self.labelOfparentname.text = model.parentname;
    self.labelOfBeenstr.text = model.beenstr;
    self.labelOfEnname.text = model.enname;
    self.labelOfCnnamel.text = model.cnname;
}
@end
